package com.example.smartcity.ui.Tools;


import android.content.Context;
import android.content.ContextWrapper;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class File extends ContextWrapper {
    public File(Context base) {
        super(base);
    }

    public void saveFile(String fileName, String Content){
        try{
            FileOutputStream fileOutputStream = null;
            BufferedWriter bufferedWriter = null;
            fileOutputStream = openFileOutput(fileName,MODE_PRIVATE);
            bufferedWriter = new BufferedWriter(new OutputStreamWriter(fileOutputStream));
            bufferedWriter.write(Content);
            bufferedWriter.close();
            fileOutputStream.close();
        }catch (Exception e){

        }
    }

    public  String readFile(String fileName) {
        String content = null;
        try{

            FileInputStream fileInputStream =null;
            BufferedReader bufferedReader = null;
            fileInputStream = openFileInput(fileName);
            bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
            content = bufferedReader.readLine();
            bufferedReader.close();
            fileInputStream.close();
        }catch (Exception e){

        }
        return content;
    }
}
